Namespace UI

    ''' <summary>
    ''' Defines a collection of user desktop settings. This is a persistant object and should be saved with the each load
    ''' or close etc
    ''' </summary>
    ''' <remarks></remarks>
    <Serializable(), ObfuscationAttribute(Exclude:=True, ApplyToMembers:=True)> _
    Public Class UserDesktopSettingsCollection
        Inherits ObjectModel.KeyedCollection(Of String, UI.UserDesktopSettings)

        Private mCurrentDesktop As UserDesktopSettings = Nothing

        ''' <summary>
        ''' Initialised the User Desktop Settings and adds the default one
        ''' </summary>
        ''' <remarks></remarks>
        Sub New()
            Me.Add(New UserDesktopSettings("Default"))
            mCurrentDesktop = Me("Default")
        End Sub

        Public Property CurrentDesktop() As UserDesktopSettings
            Get
                Return mCurrentDesktop
            End Get
            Set(ByVal value As UserDesktopSettings)
                mCurrentDesktop = value
            End Set
        End Property

        Public Sub DeleteCurrentDesktop()
            If Not mCurrentDesktop Is Nothing Then
                If mCurrentDesktop.Name = "Default" Then
                    Me.Remove("Default")
                    Me.Insert(0, New UserDesktopSettings("Default"))
                Else
                    Me.Remove(mCurrentDesktop)
                    mCurrentDesktop = Me("Default")
                End If
            Else
                mCurrentDesktop = Me("Default")
            End If
        End Sub

        Protected Overrides Function GetKeyForItem(ByVal item As UserDesktopSettings) As String
            Return item.Name
        End Function

    End Class

End Namespace

